#ifndef VIRTUALFS_H
#define VIRTUALFS_H

#include <QVector>
#include <QString>
#include <QDebug>
#include <QStringList>
#include <QMutex>
#include "virtualfsobject.h"


class VirtualFs
{
public:
    VirtualFs();
    ~VirtualFs();


    int addFolder(QString folder, bool recur = 0);
    int addFile(const QString & realWay, const QString & virtualWay, const QString & name, bool recur = 0);
    bool isFolder( const QString & way );
    bool isFile( const QString & way );

    qint64 folder_indexOf(VirtualFsObject *vfs_root, const QString & name, qint64 from = 0);
    qint64 file_indexOf(VirtualFsObject *vfs_root, const QString & name, qint64 from = 0);

    VirtualFsObject *createFolder(VirtualFsObject *vfso, const QString & name);
    VirtualFsObject *createFile(VirtualFsObject *vroot, const QString & realWay, const QString & name, const QString & realName = QString());

    VirtualFsObject* folder( const QString & folder );
    VirtualFsObject* folder( VirtualFsObject *vroot, const QString & folder );
    VirtualFsObject*  file( const QString & file );
    int rm( const QString & file );
    int rmdir( const QString & dir );
    int rename(const QString & obj, const QString & to);
    bool isNameValid(const QString & name);
    qint64 clear(VirtualFsObject* vfs_root);

    VirtualFsObject *root() {
        return &_root;
    }

    void dump(VirtualFsObject * root);
private:
    VirtualFsObject _root;
    QMutex mutex;
};

#endif // VIRTUALFS_H
